class_name WeaponBehavior
extends Node2D

@export var weapon: Weapon

var critical := false

func execute_attack() -> void:
	pass
	
func get_damage() -> float:
	var damage := weapon.data.stats.damage + Global.player.stats.damage
	var crit_chance := weapon.data.stats.crit_chance
	if Global.is_chance_success(crit_chance):
		critical = true
		damage = ceil(damage * weapon.data.stats.crit_damage)
	return damage

func apply_life_steal() -> void:
	var chance := (Global.player.stats.life_steal / 100.0) + weapon.data.stats.life_steal
	var can_steal := Global.is_chance_success(chance)
	if can_steal:
		Global.player.heal(1.0)
